package br.com.cotec.model;

import javax.persistence.Basic;	
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 * @author <a href="mailto:rsilvamagalhaes@gmail.com">Rodrigo S Magalhaes</a>
 *
 */
@Entity
@Table(name = "fileira")
public class Fileira {
	private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Long id;
    @Column(name = "ordem")
    private Long ordem;
    @JoinColumn(name = "sala", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Sala sala;
    
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public Long getOrdem() {
		return ordem;
	}
	public void setOrdem(Long ordem) {
		this.ordem = ordem;
	}
	
	public Sala getSala() {
		return sala;
	}
	public void setSala(Sala sala) {
		this.sala = sala;
	}
	@Override
	public boolean equals(Object object) {
		if (!(object instanceof Fileira)) {
			return false;
		}
		Fileira other = (Fileira) object;
		String este = ""+this.getId()+this.getOrdem();
		String outro = ""+other.getId()+other.getOrdem();
		return este.equalsIgnoreCase(outro);
	}
	
	@Override
	public int hashCode() {
		String aux = ""+this.id+this.ordem;
		return aux.hashCode();
	}
}
